//
//  MainTainViewController.swift
//  cloudShop
//
//  Created by jing99 on 2019/1/3.
//  Copyright © 2019 京贝尔. All rights reserved.
//

import UIKit

class MainTainViewController: UIViewController,UITableViewDelegate,UITableViewDataSource{

    
    var tableView : UITableView!
    var dataSuorceArray = ["123","456","789"]
    var sureButton : UIButton!
    var topView : UIView!
    var topImgView:UIImageView!
    var shopName:UILabel!
    var phoneNub:UILabel!
    var stateButton:UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title="维护"
        view .addSubview(tableView)
        
        view.backgroundColor = UIColor.white
        tableView=UITableView(frame: self.view.bounds)
        tableView.delegate=self
        tableView.dataSource=self
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "CellID")
        
        sureButton = UIButton(frame: CGRect(x: 20,
                                                  y: self.view.frame.size.width - 45 - 40,
                                                  width: self.view.frame.size.width,
                                                  height: 45))
        sureButton.layer.cornerRadius=10
        sureButton.layer.masksToBounds=true
        sureButton.titleLabel?.text="查看店铺"
        sureButton.titleLabel?.textColor=UIColor.white
        let layer = CAGradientLayer()
        layer.frame = sureButton.bounds
        layer.colors = [UIColor(0xF43400).cgColor, UIColor(red: 0.9, green: 0, blue: 0.18, alpha: 1).cgColor]
        layer.locations = [0, 1]
        layer.frame = sureButton.bounds
        layer.startPoint = CGPoint(x: 0.04, y: 0.18)
        layer.endPoint = CGPoint(x: 0.86, y: 0.86)
        sureButton.layer.addSublayer(layer)
        view.addSubview(sureButton)
        
        initTableViewTopView()
        
    
    }
    func initTableViewTopView(){
        topView = UIView(frame: CGRect(x:0,
                                       y:0,
                                       width:self.view.frame.size.width,
                                       height:140))
        let bgLayer1 = CAGradientLayer()
        bgLayer1.colors = [UIColor(red: 1, green: 0.46, blue: 0.01, alpha: 1).cgColor, UIColor(red: 0.9, green: 0, blue: 0.18, alpha: 1).cgColor]
        bgLayer1.locations = [0, 1]
        bgLayer1.frame = topView.bounds
        bgLayer1.startPoint = CGPoint(x: 0.04, y: 0.18)
        bgLayer1.endPoint = CGPoint(x: 0.86, y: 0.86)
        topView.layer.addSublayer(bgLayer1)
        view.addSubview(topView)
    }
    public override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
    }
    
    public override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 80
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSuorceArray.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = (tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath))
        cell.textLabel?.text = dataSuorceArray[indexPath.row]
        if indexPath.row == 0 {
            cell.backgroundColor = UIColor.red
        }else if indexPath.row == 1{
            cell.backgroundColor = UIColor.blue
        }else{
            cell.backgroundColor = UIColor.green
        }
        return cell
    }
    
}
